package com.fate.securecheckplatform.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Author:   RandBII
 * DATE:   2020/1/9
 * Description: 管理线程
 */
public class ExecutorManager {

    private static ExecutorService service;

    static {
        service = new ThreadPoolExecutor(3, 5,
                2000L, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
    }

    public static ExecutorService getService() {
        if (service == null) {
            try {
                throw new Exception("ExecutorManager 类中service 不可为空");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return service;
    }


}
